/***********************************************************************
 * Module:  BlogTitle.java
 * Author:  HiWin10
 * Purpose: Defines the Class BlogTitle
 ***********************************************************************/
package com.ccq.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "blogTitle")
public class BlogTitle {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	@Column
	private String title;

	@ManyToOne
	@JoinColumn(name = "authorId")
	private User author;

	@Column
	@Temporal(TemporalType.TIME)
	private Date createTime;

	@Column
	private int commentNum;

	@Column
	private int favNum;

	@OneToOne(mappedBy="blogTitle")
	private BlogDetail blogDetail;
	
	@OneToMany(mappedBy="blogTitle",fetch=FetchType.EAGER)
	private Set<Comment> comments = new HashSet<Comment>();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public int getCommentNum() {
		return commentNum;
	}

	public void setCommentNum(int commentNum) {
		this.commentNum = commentNum;
	}

	public int getFavNum() {
		return favNum;
	}

	public void setFavNum(int favNum) {
		this.favNum = favNum;
	}

	public BlogDetail getBlogDetail() {
		return blogDetail;
	}

	public void setBlogDetail(BlogDetail blogDetail) {
		this.blogDetail = blogDetail;
	}

	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}
	
	

}